<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/head.jsp" />
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>

<form class="layui-form layui-form-pane" id="_form">
    <input type="hidden" name="id" value="${position.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">岗位名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入岗位名称"
                   class="layui-input" value="${position.name}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">请选择父岗位</label>
        <div class="layui-input-block ztreeDiv">
            <input type="text" readonly="readonly" id="pid" value="${parentPosition.name}"
                   autocomplete="off" placeholder="请选择父岗位" class="layui-input" onclick="ZtreeCommon.showMenu(this)"
                   ztreeId="ztree">
            <input type="hidden" name="pid" id="pid_value" ztreeId="ztree" value="${parentPosition.id}">
        </div>
        <div class="menuContent" style="display:none; position: absolute;z-index: 10000">
            <ul id="ztree" class="ztree" style="margin-top:0; width:220px;"></ul>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" lay-verify="number" autocomplete="off" placeholder="请输入排序"
                   class="layui-input" value="${position.sort}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职能类型</label>
        <div class="layui-input-block">
            <select name="type" lay-verify="required">
                <c:forEach items="${fns:getDictList('position_type')}" var="type">
                    <option value="${type.value}"
                            <c:if test="${position.type == type.value}">
                                selected
                            </c:if>
                    >${type.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">岗位级别</label>
        <div class="layui-input-block">
            <select name="level" lay-verify="required">
                <c:forEach items="${fns:getDictList('position_level')}" var="level">
                    <option value="${level.value}"
                            <c:if test="${position.level == level.value}">
                                selected
                            </c:if>
                    >${level.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职责</label>
        <div class="layui-input-block">
            <textarea name="duty" autocomplete="off" placeholder="请输入职责" class="layui-textarea">${position.duty}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">入职要求</label>
        <div class="layui-input-block">
            <textarea name="requirement" autocomplete="off" placeholder="请输入入职要求" class="layui-textarea">${position.requirement}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">岗位工作概述</label>
        <div class="layui-input-block">
            <textarea name="description" autocomplete="off" placeholder="请输入岗位工作概述" class="layui-textarea">${position.description}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注" class="layui-textarea">${position.remark}</textarea>
        </div>
    </div>

    <div class="layui-form-item" style="margin-top: 50px;">
        <div class="layui-input-block" style="float: right">
            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script src="${basePath}/resources/zheng-admin/js/my-ztree-common.js"></script>
<script>
    var zNodes = getPositionTree(true, false);
    var selectedId = ${parentPosition.id};
    $(zNodes).each(function (index, node) {
        if (node.id == selectedId) {
            node.checked = true;
            return false;
        }
    });
    FormCommon.initForm({
        url: "${basePath}/oa/hr/position/update",
        subId: "sub",
        afterCommit:function () {
            parent.refreshTree();
            if (!parent.$table) {
                parent.refresh();
            } else {
                parent.$table.bootstrapTable('refresh');
            }
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        }
    });
    $(function () {
        $.fn.zTree.init($("#ztree"),ZtreeCommon.radioAllSetting, zNodes);
    });
</script>
</body>
</html>
